// Audio.h: interface for the CAudio class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_AUDIO_H__ACD823CA_39B7_4473_88CB_3DF8111BC56F__INCLUDED_)
#define AFX_AUDIO_H__ACD823CA_39B7_4473_88CB_3DF8111BC56F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <mmsystem.h>
#include "AudioDX.h"
#include "audioWM.h"
//#define _DXSOUND				// using directx sound
#include <list>
#include <queue>
using namespace std;
typedef list<XAUDIOPACKET*> LSTAUDIOPACKET;
#include <afxmt.h>
#include "AudioQueue.h"

class CAudio  : public CAudioQueue
{
public:

	CAudio();
	virtual ~CAudio();
protected:
	BOOL			bAudioAvailable;
	DWORD			deviceID;
	int				nCodec;
	WAVEFORMATEX	myWaveFormat;
	int				PacketSize;
	LPVOID			m_PlayerInfo;	
	DWORD			dwAudioFormat;
	BOOL			bInitialized;
	
public:
#if defined(_DXSOUND)
	CAudioDX	 *		m_pSoundPlayer;
#else
	CAudioWM	*		m_pSoundPlayer;
#endif
	LSTAUDIOPACKET		m_lstAudioPacket;
	BOOL				m_bRunThread;
	CCriticalSection	csBuffer;
	CCriticalSection	csStatus;
	HANDLE				m_hPlayer;
	BOOL				m_bPlay;
	BOOL				m_bMute;
	int					m_nSampleFormat;

public:
	BOOL AudioOut(DWORD codec, DWORD sample, BYTE * buf, int len, FILETIME * ftStart);
	void SetMute(BOOL bMute);
	
	BOOL StartPlay();
	BOOL StopPlay();
	
	BOOL IsInitialized();
	BOOL AudioOut(BYTE *data, int len, FILETIME *ftStart = NULL);
	void SetCodec(DWORD dwformat, int packet_size);
	int GetVolume();
	void SetVolume(int vol);
	BOOL IsAudioAvailable();
	void Finalize();
	BOOL Initialize(HWND hWnd);
	static	unsigned int WINAPI	AudioPlayerThreadProc(LPVOID lParam);
};

#endif // !defined(AFX_AUDIO_H__ACD823CA_39B7_4473_88CB_3DF8111BC56F__INCLUDED_)
